export default {
    state: {
        isCollapse: false,
        tabsList: [
            {
                path:'/home',
                name:'首页',
                description:'Home',
                icon:'home'
            }
        ],
        nav:[],
        // token:localStorage.getItem('token') ? localStorage.getItem('token'):'',
        token:sessionStorage.getItem('token') ? sessionStorage.getItem('token'):'',
        currentMenu:null
    },
    mutations: {
        collapseMenu(state) {
            state.isCollapse = !state.isCollapse
        },
        selectMenu(state,val){
            if(val.path!=='/home'){
                state.currentMenu=val
                const result=state.tabsList.findIndex(item=> item.path ===val.path)
                if(result==-1){
                    state.tabsList.push(val)
                }
            }else{
                state.currentMenu=null
            }
        },
        closeTag(state,val){
            const result=state.tabsList.findIndex(item=>item.path===val.path)
            state.tabsList.splice(result,1)
        },
        $_setToken(state, value) { // 设置存储token
            state.token = value;
            sessionStorage.setItem('token', value);
        },
        $_removeStorage(state, value) {  // 删除token
            state.token=''
            sessionStorage.removeItem('token');
        },
        SETNAV(state,data){
            state.nav=data
        }
        },
        actions:{
            SETNAV({commit},data){
                commit('SETNAV',data)
            }
        }
}